<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Spec::Mocks::ArgumentConstraints</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Spec::Mocks::ArgumentConstraints</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/mocks/argument_constraints_rb.html">
                vendor/plugins/rspec/lib/spec/mocks/argument_constraints.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
<a href="ArgumentConstraints.html">ArgumentConstraints</a> are messages
that you can include in message expectations to match arguments against a
broader check than simple equality.
</p>
<p>
With the exception of <a
href="ArgumentConstraints.html#M000175">any_args</a>() and <a
href="ArgumentConstraints.html#M000177">no_args</a>(), the constraints are
all positional - they match against the arg in the given position.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000175">any_args</a>&nbsp;&nbsp;
      <a href="#M000176">anything</a>&nbsp;&nbsp;
      <a href="#M000179">boolean</a>&nbsp;&nbsp;
      <a href="#M000178">duck_type</a>&nbsp;&nbsp;
      <a href="#M000180">hash_including</a>&nbsp;&nbsp;
      <a href="#M000177">no_args</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Class <a href="ArgumentConstraints/AnyArgConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::AnyArgConstraint</a><br />
Class <a href="ArgumentConstraints/AnyArgsConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::AnyArgsConstraint</a><br />
Class <a href="ArgumentConstraints/BooleanConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::BooleanConstraint</a><br />
Class <a href="ArgumentConstraints/DuckTypeConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::DuckTypeConstraint</a><br />
Class <a href="ArgumentConstraints/EqualityProxy.html" class="link">Spec::Mocks::ArgumentConstraints::EqualityProxy</a><br />
Class <a href="ArgumentConstraints/HashIncludingConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::HashIncludingConstraint</a><br />
Class <a href="ArgumentConstraints/MatcherConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::MatcherConstraint</a><br />
Class <a href="ArgumentConstraints/NoArgsConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::NoArgsConstraint</a><br />
Class <a href="ArgumentConstraints/RegexpConstraint.html" class="link">Spec::Mocks::ArgumentConstraints::RegexpConstraint</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000175" class="method-detail">
        <a name="M000175"></a>

        <div class="method-heading">
          <a href="#M000175" class="method-signature">
          <span class="method-name">object.should_receive(:message).with(any_args())<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes if object receives :message with any args at all. This is really a
more explicit variation of object.should_receive(:message)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000175-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000175-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_constraints.rb, line 111</span>
111:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">any_args</span>
112:         <span class="ruby-constant">AnyArgsConstraint</span>.<span class="ruby-identifier">new</span>
113:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000176" class="method-detail">
        <a name="M000176"></a>

        <div class="method-heading">
          <a href="#M000176" class="method-signature">
          <span class="method-name">object.should_receive(:message).with(anything())<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes as long as there is an argument.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000176-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000176-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_constraints.rb, line 119</span>
119:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">anything</span>
120:         <span class="ruby-constant">AnyArgConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>)
121:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000179" class="method-detail">
        <a name="M000179"></a>

        <div class="method-heading">
          <a href="#M000179" class="method-signature">
          <span class="method-name">object.should_receive(:message).with(boolean())<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes if the argument is <a
href="ArgumentConstraints.html#M000179">boolean</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000179-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000179-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_constraints.rb, line 151</span>
151:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">boolean</span>
152:         <span class="ruby-constant">BooleanConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>)
153:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000178" class="method-detail">
        <a name="M000178"></a>

        <div class="method-heading">
          <a href="#M000178" class="method-signature">
          <span class="method-name">object.should_receive(:message).with(duck_type(:hello))<br />
object.should_receive(:message).with(duck_type(:hello, :goodbye))<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes if the argument responds to the specified messages.
</p>
<h2>Examples</h2>
<pre>
  array = []
  display = mock('display')
  display.should_receive(:present_names).with(duck_type(:length, :each))
  =&gt; passes
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000178-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000178-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_constraints.rb, line 143</span>
143:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">duck_type</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
144:         <span class="ruby-constant">DuckTypeConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
145:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000180" class="method-detail">
        <a name="M000180"></a>

        <div class="method-heading">
          <a href="#M000180" class="method-signature">
          <span class="method-name">object.should_receive(:message).with(hash_including(:this => that))<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes if the argument is a hash that includes the specified key/value
pairs. If the hash includes other keys, it will still pass.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000180-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000180-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_constraints.rb, line 160</span>
160:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hash_including</span>(<span class="ruby-identifier">expected</span>={})
161:         <span class="ruby-constant">HashIncludingConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">expected</span>)
162:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000177" class="method-detail">
        <a name="M000177"></a>

        <div class="method-heading">
          <a href="#M000177" class="method-signature">
          <span class="method-name">object.should_receive(:message).with(no_args)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes if no arguments are passed along with the message
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000177-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000177-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_constraints.rb, line 127</span>
127:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">no_args</span>
128:         <span class="ruby-constant">NoArgsConstraint</span>.<span class="ruby-identifier">new</span>
129:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>